Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@opentelemetry/propagator-b3
Advanced tools
OpenTelemetry B3 propagator provides context propagation for systems that are using the B3 header format
The @opentelemetry/propagator-b3 npm package is used for B3 propagation format which is a convention for passing trace context information across service boundaries. It supports both single-header and multi-header encoding. This package is part of the OpenTelemetry project which provides a collection of tools, APIs, and SDKs to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) to help analyze a software's performance and behavior.
B3 Propagation
This feature allows the user to extract and inject B3 propagation headers. The B3Propagator can be set as the global propagator in OpenTelemetry.
const { B3Propagator } = require('@opentelemetry/propagator-b3');
const { propagation } = require('@opentelemetry/api');
// Use the B3Propagator for extracting and injecting
propagation.setGlobalPropagator(new B3Propagator());
B3 Multi-header Propagation
This feature supports the B3 multi-header propagation format, which uses multiple headers to transmit tracing information. It is useful when interacting with systems that expect B3 headers in multiple header format.
const { B3MultiPropagator } = require('@opentelemetry/propagator-b3');
const { propagation } = require('@opentelemetry/api');
// Use the B3MultiPropagator for extracting and injecting with multi-header support
propagation.setGlobalPropagator(new B3MultiPropagator());
This package is a Node.js client for Jaeger, a distributed tracing system. It includes Jaeger Tracer which can report tracing information to a Jaeger agent or collector. Jaeger and B3 are both tracing propagation formats, but Jaeger is specific to the Jaeger tracing system, whereas B3 is a more general format used by systems like Zipkin.
The Zipkin npm package is a library that interfaces with the Zipkin API for distributed tracing. Similar to B3, Zipkin uses B3 propagation headers for tracing across service boundaries. The Zipkin package provides more comprehensive features for interacting with Zipkin, while @opentelemetry/propagator-b3 focuses on the propagation aspect within the OpenTelemetry ecosystem.
LightStep's tracer library for Node.js is designed to monitor the performance of distributed systems. It uses its own propagation format and is part of the LightStep ecosystem, which is a different distributed tracing solution compared to the B3 propagation used by @opentelemetry/propagator-b3.
The OpenTelemetry b3 propagator package provides multiple propagator implementations for systems using the b3 context format. See the b3 specification for complete details.
Single-Header Format:
b3: {TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
Multi-Header Format:
X-B3-TraceId: {TraceId}
X-B3-SpanId: {SpanId}
X-B3-ParentSpanId: {ParentSpanId}
X-B3-Sampled: {SamplingState}
{TraceId}
{SpanId}
{ParentSpanId}
{SamplingState} - Single-header
{SamplingState} - Multi-header
{Flags} - Multi-header
X-B3-Flags
: 1. Absent or any other value can be ignored. Debug implies an accept decision, so don't also send the X-B3-Sampled
header.The default B3Propagator
implements b3 propagation according to the
OpenTelemetry specification. It extracts b3 context
from multi and single header encodings and injects context using the
single-header b3 encoding by default. The inject encoding can be changed to
multi-header via configuration. See the examples below.
const api = require('@opentelemetry/api');
const { B3Propagator } = require('@opentelemetry/propagator-b3');
api.propagation.setGlobalPropagator(new B3Propagator());
const api = require('@opentelemetry/api');
const { B3Propagator } = require('@opentelemetry/propagator-b3');
api.propagation.setGlobalPropagator(
new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER })
);
The B3Propagator always extracts both the single and multi-header b3 encodings. If you need to inject both encodings this can accomplished using a composite propagator.
const api = require('@opentelemetry/api');
const { B3Propagator } = require('@opentelemetry/propagator-b3');
api.propagation.setGlobalPropagator(
new CompositePropagator({
propagators: [
new B3Propagator(),
new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }),
],
})
);
Apache 2.0 - See LICENSE for more information.
FAQs
OpenTelemetry B3 propagator provides context propagation for systems that are using the B3 header format
The npm package @opentelemetry/propagator-b3 receives a total of 2,517,947 weekly downloads. As such, @opentelemetry/propagator-b3 popularity was classified as popular.
We found that @opentelemetry/propagator-b3 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.